
package pri.syl.xiaowu.websocket.netty.server.thread.execution;

import  pri.syl.xiaowu.websocket.core.exception.WebsocketException;
import  pri.syl.xiaowu.websocket.netty.server.handler.core.factory.execution.HandshakeFactoryExecution;
import  pri.syl.xiaowu.websocket.netty.server.thread.AbstractHttpServerHandshakeThread;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.FullHttpRequest;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author YunLong
 * @Date 2021/7/18 19:19
 * @Description  握手执行逻辑
 **/
@Slf4j
public class HttpServerHandshakeThreadExecution extends AbstractHttpServerHandshakeThread {

    public HttpServerHandshakeThreadExecution(Channel channel, FullHttpRequest request, int maxFramePayloadLength, int readTimeoutMilli) {
        super (channel, request, maxFramePayloadLength, readTimeoutMilli);
    }

    @Override
    protected void httpServerHandshake(Channel channel, FullHttpRequest request, int maxFramePayloadLength, int readTimeoutMilli) {
        try {
            HandshakeFactoryExecution.upgradeWebsocket (channel, request, maxFramePayloadLength, readTimeoutMilli);
        } catch (WebsocketException websocketException) {
            channel.close ();
            log.error ("httpServerHandshake Error", websocketException);
        }
    }
}
